package leetcode.linkedlist;

import leetcode.linkedlist.common.LinkedListUtils;
import leetcode.linkedlist.common.ListNode;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution61 {
    public ListNode rotateRight(ListNode head, int k) {
        return LinkedListUtils.rotateRight(head, k);
    }
}

public class leetcode61 {
    public static void main(String[] args) {
        Solution61 solution61 = new Solution61();
        int[] nums =  {1,2,3,4,5};
        test61(solution61, nums, 2);
    }

    private static void test61(Solution61 solution61, int[] nums, int k) {
        ListNode head = LinkedListUtils.generateLinkedListByArray(nums);
        ListNode result = solution61.rotateRight(head, k);
        System.out.println(LinkedListUtils.getLinkedListVals(result));
    }
}
